<?php
// +----------------------------------------------------------------------
// | OneKeyAdmin [ Believe that you can do better ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2023 http://onekeyadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: MUKE <513038996@qq.com>
// +----------------------------------------------------------------------
namespace plugins\cms\api\controller;

use think\exception\ValidateException;
use app\api\BaseController;
use plugins\cms\api\validate\Job as Validate;
use plugins\cms\api\model\JobResume;
/**
 * 我的下载
 */
class UserJobResume extends BaseController
{
    /**
     * 用户权鉴
     */
    public $middleware = [\app\api\middleware\AuthCheck::class];
    
    /**
     * 已下载列表
     */
    public function index()
    {
        if ($this->request->isPost()) {
            try {
                $input = input('post.');
                validate(Validate::class)->scene('resumeIndex')->check($input);
            } catch ( ValidateException $e ) {
                return json(['status' => 'error', 'message' => $e->getError()]);
            }
            $where[] = ['user_id', '=', $this->request->userInfo->id];
            $search = ['keyword', 'date'];
            $order  = ['create_time' => 'desc'];
            $count = JobResume::where($where)->withSearch($search, $input)->count();
            $data  = JobResume::where($where)->withSearch($search, $input)->with(['job'])->order($order)->page($input['page'], 10)->select();
            return json(['status' => 'success', 'message' => '获取成功', 'data' => $data, 'count' => $count]);
        }
    }
}